import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {SysDemandForm, SysDemandQuery} from "@/api/demand/types";

/**
* 用户需求表数据
*
* @param queryParams
*/
export function getSysDemandPage(
queryParams: SysDemandQuery
): AxiosPromise<PageResult<[]>> {
return request({
url: '/api/v1/demand/page',
method: 'get',
params: queryParams
});
}


/**
* 获取用户需求表表单数据
*
* @param queryParams
*/
export function getSysDemandForm(id: number): AxiosPromise<SysDemandForm> {
    return request({
    url: '/api/v1/demand/' + id + '/form',
    method: 'get'
    });
    }

    /**
    * 保存用户需求表
    *
    * @param data
    */
    export function saveSysDemand(data: SysDemandForm) {
    return request({
    url: "/api/v1/demand",
    method: "post",
    data: data,
    });
    }

    /**
    * 删除用户需求表
    *
    * @param ids
    */
    export function deleteSysDemand(ids: string) {
        return request({
        url: '/api/v1/demand/' + ids,
        method: 'delete'
        });
    }

    /**
    * 导入用户需求表
    *
    * @param file
    */
    export function importSysDemand(file: any) {
        const formData = new FormData();
        formData.append('file', file);
        return request({
            url: '/api/v1/demand/sysDemandImport',
            method: 'post',
            data: formData,
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        });
    }

    /**
    * 导出用户需求表
    *
    * @param ids
    * @returns
    */
    export function exportSysDemand(ids: any) {
        return request({
            url: '/api/v1/demand/_export?ids='+ids,
            method: 'get',
            responseType: 'arraybuffer'
        });
    }

/**
 * 保存处理结果
 *
 * @param data
 */
export function updateResult(data: SysDemandForm) {
	return request({
		url: "/api/v1/demand/updateResult",
		method: "post",
		data: data,
	});
}
